package stark.app.function.visualai;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import stark.app.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

/**
 * Author：daizhongbin on 2023/10/11
 * Email：1027154338@qq.com
 * Desc:
 */
public class VisualAiFuncActionAdapter extends StkProviderMultiAdapter<String> {

    private int selPos = 0;

    public VisualAiFuncActionAdapter() {
        super(1);
        addItemProvider(new ItemProvider());
    }

    public void setSelPos(int selPos) {
        if (this.selPos != selPos) {
            this.selPos = selPos;
            notifyDataSetChanged();
        }
    }

    private class ItemProvider extends BaseItemProvider<String> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_visual_ai_func_action;
        }

        @Override
        public void convert(@NonNull BaseViewHolder holder, String text) {
            int pos = holder.getBindingAdapterPosition();
            holder.itemView.setSelected(pos == selPos);
            holder.setText(R.id.tvName, text);
        }
    }

}
